System Design
The Hridaya Steam Market Tracker is a sophisticated async Python data platform designed to continuously track Steam Community Market data while respecting API rate limits. The architecture follows a coordinated scheduler pattern with shared rate limiting.Core Components
Orchestrator
Central coordinator that initializes and manages all schedulers with graceful shutdown
Rate Limiter
Sliding window algorithm ensuring API compliance across all concurrent requests
Schedulers
Dual scheduling system: urgency-based (snoozer) and fixed-interval (clockwork)
API Client
Async HTTP client with automatic data validation and error handling
Architecture Diagram
Data Flow
1. Initialization Phase
- Required fields per endpoint type
- Rate limit feasibility calculation
- Startup burst warnings
2. Runtime Phase
Both schedulers run concurrently, sharing a singleRateLimiter instance:
3. Request Execution
Every API call follows this pattern:- Maximum N requests per window (configured in
config.yaml) - No request proceeds without a token
- Automatic queuing when limit is reached
Configuration-Driven Design
The system is entirely controlled byconfig.yaml:
Endpoint Scheduling Strategy
| Endpoint | Scheduler | Reason |
|---|---|---|
priceoverview | snoozerScheduler | Real-time price updates (every 5-60s) |
itemordershistogram | snoozerScheduler | Live order book changes |
itemordersactivity | snoozerScheduler | Recent transaction feed |
pricehistory | ClockworkScheduler | Steam updates hourly, no benefit to polling faster |
Error Handling & Resilience
Exponential Backoff (snoozerScheduler)
Transient errors (429, 5xx, network) trigger exponential backoff:- 1st error: skip 1 interval
- 2nd consecutive: skip 2 intervals
- 3rd consecutive: skip 4 intervals
- 4th+ consecutive: skip 8 intervals (capped)
Fixed Retry Logic (ClockworkScheduler)
Historical data uses fixed retry delays:Graceful Shutdown
Signal handlers ensure clean termination:Database Storage
All fetched data is stored in SQLite (data/market_data.db) via the SQLinserts class:
Performance Characteristics
Startup Behavior
Startup Behavior
All items fire immediately on first run (urgency = ∞). The rate limiter queues them automatically.Example: 50 items configured → all 50 attempt to execute → rate limiter serializes them.
Steady-State Behavior
Steady-State Behavior
Items spread out naturally based on urgency scores. High-frequency items (30s polling) execute more often than low-frequency items (300s polling).The system sleeps when no items are urgent, waking only when the next item becomes overdue.
Rate Limit Utilization
Rate Limit Utilization
The orchestrator calculates capacity usage:This assumes worst-case (all items synchronized). Real utilization is typically lower due to urgency-based spreading.
Next Steps
Orchestrator Deep Dive
Learn about configuration validation and scheduler coordination
Rate Limiter Algorithm
Understand the sliding window log implementation
Scheduler Strategies
Explore urgency-based vs fixed-interval scheduling
Configuration Guide
Set up your tracking configuration